package jsen.tool.ddd.adapter.infrastructure.specification.demo.spec.send;

import jsen.tool.ddd.adapter.infrastructure.specification.ISpecification;
import jsen.tool.ddd.adapter.infrastructure.specification.base.SpecContext;

/**
 * @author jsen
 * @date 2021/10/6
 * <p>
 * 名字和别名不能相同
 */
class SendMethodAgeSpec implements ISpecification<Integer> {

    @Override
    public boolean isSatisfiedBy(SpecContext<Integer> t) {
        Integer age = t.getData();
        boolean ageValid = age != null && age > 0;
        if (!ageValid) {
            t.addError("SendMethodAgeSpec", "age必须大于0");
        }
        return ageValid;
    }
}
